<template>
  <div class="topcard">
    <div class="topcard-wrap" @click="toTopPage">
      <div class="top-sign" :style="{ 'background': CPNcolor }">
        <span class="top-sign-bd">
          <slot name="bd-label"></slot>
        </span>
        <div class="mask">
          <div class="small">
            <slot name="s-label"></slot>
          </div>
          <div class="large">
            <slot name="l-label"></slot>
          </div>
        </div>
      </div>
      <div class="top3"
        :style="{ 'background': `url(${require('@/assets/img/' + CPNimgurl)}) center center / cover no-repeat` }">
        <div class="mask">
          <div v-for="(item, index) in data.slice(0, 3)" :key="index">
            <div class="van-ellipsis top3-name">{{ index + 1 }}.{{ item.name }}</div>
            <div class="van-ellipsis top3-author"> {{ item.author }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    CPNimgurl: String,
    type: String,
    CPNcolor: {
      type: String,
      default: 'rgb(74, 68, 76)'
    },
    data: Array
  },
  methods: {
    toTopPage() {
      this.$router.push({
        name: 'topRankView',
        params: { data: this.data, title: this.type == 'week' ? '周榜' : '总榜', sign: this.type == 'week' ? 'TOPWEEK' : 'TOPALL' }
      })
    }
  }
}
</script>

<style>
.topcard {
  padding: 0 15px;
  margin-bottom: 12px;
}

.topcard-wrap {
  display: flex;
  height: 100px;
}

.top-sign {
  flex: 100px 0 0;
  border-radius: 4px 0 0 4px;
  overflow: hidden;
}

.top-sign-bd {
  font-size: 28px;
  opacity: .1;
  color: hsla(0, 0%, 100%, .9);
}

.top-sign,
.top3 {
  line-height: 100px;
  text-align: center;
  position: relative;
}

.top3 {
  flex: 1;
  border-radius: 0 4px 4px 0;
}

.mask {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100px;
  line-height: 1.4;
  font-size: 13px;
  color: #fff;
}

.top-sign .mask {
  background: rgba(0, 0, 0, 0);
}

.top3 .mask {
  border-radius: 0 4px 4px 0;
  background: rgba(74, 68, 76, .8);
  text-align: left;
}

.mask .small {
  color: hsla(0, 0%, 100%, .6);
  font-size: 13px;
}

.mask .large {
  font-size: 17px;
  color: hsla(0, 0%, 100%, .9);
}

.top3 .top3-name {
  display: inline-block;
  vertical-align: text-bottom;
  text-indent: 15px;
  max-width: 165px;
}

.top3-author {
  display: inline-block;
  vertical-align: text-bottom;
  text-indent: 6px;
  font-size: 12px;
  color: #ffac2d;
  max-width: 80px;
}
</style>